<?php
class Controller
{
	protected $wbClient = NULL;
	public $login_user = FALSE;
	public $smarty = NULL;
	public function __construct()
	{
		$this->smarty = Util::getTpl();
		$this->login_user = $this->IsLogin();
		if (!$this->login_user) header('Location: /user/login');
		$this->smarty->assign('login_user', $this->login_user);
	}
	
	public function Index()
	{
		echo '404';
	}
	
	public function IsLogin()
	{
		if (isset($_SESSION['last_key'])){
			$wbClient = new SaeTClient(Config::$WB_AKEY, 
				Config::$WB_SKEY, 
				$_SESSION['last_key']['oauth_token'],
				$_SESSION['last_key']['oauth_token_secret']
			);
			$this->wbClient = $wbClient;
			$userInfo = $this->wbClient->verify_credentials($_SESSION['last_key']['user_id']);
			if ($userInfo)
				return $userInfo;
		}
		return false;
	}
	
	public function __call($name, $arguments)
	{
		exit('Access Forbidden!');
	}
	
	public function __get($name)
	{
		exit('Access Forbidden!');
	}
	
}